home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
3_0
/
MDEF__
/
XFER_MDE.C
< prev
Wrap
C/C++ Source or Header
|
1987-11-28
|
2KB
|
79 lines
#include "MacTypes.h"
#include "stdio.h"
/*
Quick and dirty code to extract the MDEF resource id of 130 from the
file "MDEF Code", and place it into the "SHELL.RSRC" file. Nothing in
the way of error-checking going on here. Obviously, all files must
be in the same HFS folder, otherwise you'll need to put full path
names in the OpenResFile() calls.
*/
main()
{
int thefile;
Handle theres,oldres;
char ch;
Click_On(FALSE);
printf("\fResource Manager Call Resource Error");
printf("\n--------------------- --------------");
thefile = OpenResFile("\pMDEF Code");
perr("OpenResFile",ResError());
theres = GetResource('MDEF',130);
perr("GetResource",ResError());
DetachResource(theres);
perr("DetachResource",ResError());
CloseResFile(thefile);
perr("CloseResFile",ResError());
thefile = OpenResFile("\ppatmenudemo.rsrc");
perr("OpenResFile",ResError());
oldres = GetResource('MDEF',130);
perr("GetResource",ResError());
if (oldres != 0L){
RmveResource(oldres);
perr("RmveResource",ResError());
}
AddResource(theres,'MDEF',130,"\pPattern Menu");
perr("AddResource",ResError());
CloseResFile(thefile);
perr("CloseResFile",ResError());
printf("\n\n\nFinished. Press Any Key");
do{
}
while( (ch = getchar()) =='');
}
perr(astr,errcode)
char *astr;
int errcode;
{
char *errinterp[80];
printf("\n%16s%20d",astr,errcode);
if (errcode != 0){
finderr(errcode,errinterp);
printf("%30s",errinterp);
}
}
finderr(errcode,interpretation)
int errcode;
char *interpretation;
{
switch(errcode){
case -192: strcpy(interpretation,"resNotFound");
break;
case -193: strcpy(interpretation,"resFNotFound");
break;
case -194: strcpy(interpretation,"addResFailed");
break;
case -196: strcpy(interpretation,"rmvResFailed");
break;
case -43: strcpy(interpretation,"fnfErr");
break;
default: strcpy(interpretation,"undefined error");
break;
}
}